package com.tedu.api.list;

import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Queue;

public class 作业2 {
    public static void main(String[] args) {
            Queue<Integer> queue=new LinkedList<>();
            queue.add(1);
        queue.add(2);
        queue.add(3);

        System.out.println("Peek:"+queue.peek());
        System.out.println("Poll:"+queue.poll());
        try{
            if(!queue.isEmpty()){
                System.out.println("从队列中移除2："+queue.poll());
            }
        }
        catch (NoSuchElementException e){
            System.out.println("Queue is empty,cannot pop.");
        }
        System.out.println("新的 Peek 之后的 Polling:"+queue.peek());
        //输出New Peek after Polling:3
        System.out.println("Poll 来自 空的 queue:"+queue.poll());
        //输出Poll from empty queue:null
    }
}
